<style>
.pull-right p{
    text-align: center;
}
.statitem{
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 80%;
}
th{
	text-align: center !important;
}
td{
	text-align: center !important;
	white-space: normal !important;
	word-break: break-all !important;
}
</style>
<div class="container-fluid p-t-15">
  <div class="row">
  @foreach ($types as $k => $s)
     <div class="col-lg-{{$s[4]}}">
        <div class="card bg-{{$s[3]}}">
          <div class="card-body clearfix" style='display: flex;align-items: center;justify-content: space-between;color: white;'>
            <span class="avatar-md rounded-circle bg-white bg-opacity-25 avatar-box"><i class="mdi mdi-{{$s[2]}} fs-4"></i></span>
            <div class="pull-right statitem {{$s[1]}}stat">
                <div>
                  <p class="h5 text-white m-t-0">{{$s[0]}}</p>
                  <p class="h2 text-white m-b-0">*</p>
                </div>
                <div>
                  <p class="h5 text-white m-t-0">今日</p>
                  <p class="h2 text-white m-b-0">*</p>
                </div>
                <div>
                  <p class="h5 text-white m-t-0">本月</p>
                  <p class="h2 text-white m-b-0">*</p>
                </div>
            </div>
          </div>
        </div>
      </div>
  @endforeach
  </div>
  <div class="row">
  		<div class="col-lg-12">
            <div class="card">
              <div class="card-header bg-primary" style="color: white;">代理总交易额排行榜</div>
              <div class="card-body clearfix">
              	 <table class='table table-striped rank_money'>
              	 	<thead>
              	 		<th style="min-width: 50px;">名次</th>
              	 		<th style="width: 50%;">代理</th>
              	 		<th>交易额</th>
              	 	</thead>
              	 	<tbody>
              	 		<td colspan="3">加载中</td>
              	 	</tbody>
              	 </table>
              </div>
            </div>
       </div>
  </div>
</div>
<script>
lightyear.loading('show');
@foreach ($types as $s)
getData("{{$s[1]}}");
@endforeach
function getData(type){
	$.ajax({
		url:"",
		type:"post",
		data:{op:type},
		dataType:'json',
		success:function(res){
			lightyear.loading('hide');
			for(var i in res.stat) $('.'+type+"stat").find('.h2').eq(i).html(res.stat[i]);
		}
	});
}

getRank('money');
function getRank(type){
	$.ajax({
		url:"",
		type:"post",
		data:{op:'rank',type:type},
		dataType:'json',
		success:function(res){
			lightyear.loading('hide');
			var str = '';
			for(var i in res.list){
				str += "<tr>";
				str += "<td>"+(parseInt(i)+1)+"</td>";
				str += "<td>"+res.list[i].name+"</td>";
				str += "<td>"+res.list[i].num+"</td>";
				str += "</tr>";
			}
			$(".rank_"+type+" tbody").html(str);
		}
	});
}
</script>